home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / piblist.arc / READCOMM.PAS < prev    next >
Pascal/Delphi Source File  |  1985-03-24  |  6KB  |  174 lines

  1. (*---------------------------------------------------------------------------*)
  2. (*                   Read_Command --- Read PibList command line              *)
  3. (*---------------------------------------------------------------------------*)
  4.  
  5. PROCEDURE Read_Command;
  6.  
  7. (*---------------------------------------------------------------------------*)
  8. (*                                                                           *)
  9. (*     Routine:  Read_Command                                                *)
  10. (*                                                                           *)
  11. (*     Purpose:  Read PibList command line                                   *)
  12. (*                                                                           *)
  13. (*     Calling Sequence:                                                     *)
  14. (*                                                                           *)
  15. (*        Read_Command;                                                      *)
  16. (*                                                                           *)
  17. (*     Calls:                                                                *)
  18. (*                                                                           *)
  19. (*        TextColor                                                          *)
  20. (*        KeyPressed                                                         *)
  21. (*                                                                           *)
  22. (*     Called By:   Prompt                                                   *)
  23. (*                                                                           *)
  24. (*      Remarks:                                                             *)
  25. (*                                                                           *)
  26. (*        Reads the command Line into the string "command".                  *)
  27. (*        A nul character is appended to terminate the string.               *)
  28. (*        On exit Cind = 1.                                                  *)
  29. (*                                                                           *)
  30. (*---------------------------------------------------------------------------*)
  31.  
  32. LABEL
  33.    1;
  34.  
  35. VAR
  36.    c: CHAR;
  37.  
  38. BEGIN (* Read_Command *)
  39.  
  40. 1: Textcolor( Spec_Chars_Color );
  41.  
  42.    One_Up     := FALSE;
  43.    One_Down   := FALSE;
  44.    Cind       := 0;
  45.                                    (* Read first character of command *)
  46.    READ( Kbd , c );
  47.                                    (* If escape, convert escape sequence *)
  48.                                    (* letter command.                    *)
  49.  
  50.    IF ( c = ^[ ) AND KeyPressed THEN
  51.       BEGIN
  52.  
  53.          READ( Kbd , c );
  54.  
  55.          Case ORD(c) OF
  56.  
  57.            119,
  58.             71: BEGIN
  59.                    Command[1] := 'S';
  60.                    Command[2] := '1';
  61.                    Cind       := 2;
  62.                 END;
  63.  
  64.            117,
  65.             79: BEGIN
  66.                    Command[1] := 'S';
  67.                    Command[2] := '9';
  68.                    Command[3] := '9';
  69.                    Command[4] := '9';
  70.                    Command[5] := '9';
  71.                    Command[6] := '9';
  72.                    Command[7] := '9';
  73.                    Command[8] := '9';
  74.                    Command[9] := '9';
  75.                    Cind       := 9;
  76.                 END;
  77.  
  78.             73: BEGIN
  79.                    Command[1] := '-';
  80.                    Command[2] := 'S';
  81.                    Cind       := 2;
  82.                 END;
  83.  
  84.             81: BEGIN
  85.                    Command[1] := '+';
  86.                    Command[2] := 'S';
  87.                    Cind       := 2;
  88.                 END;
  89.  
  90.             75: BEGIN
  91.                    Command[1] := '-';
  92.                    Command[2] := '1';
  93.                    Command[3] := '0';
  94.                    Command[4] := 'C';
  95.                    Cind       := 4;
  96.                 END;
  97.  
  98.             77: BEGIN
  99.                    Command[1] := '+';
  100.                    Command[2] := '1';
  101.                    Command[3] := '0';
  102.                    Command[4] := 'C';
  103.                    Cind       := 4;
  104.                 END;
  105.  
  106.             72: BEGIN
  107.                    Command[1] := '-';
  108.                    Command[2] := 'L';
  109.                    Cind       := 2;
  110.                    One_Up     := TRUE;
  111.                 END;
  112.  
  113.             80: BEGIN
  114.                    Command[1] := '+';
  115.                    Command[2] := 'L';
  116.                    Cind       := 2;
  117.                    One_Down   := TRUE;
  118.                 END;
  119.  
  120.            118: BEGIN
  121.                    Command[1] := '+';
  122.                    Command[2] := 'P';
  123.                    Cind       := 2;
  124.                 END;
  125.  
  126.            132: BEGIN
  127.                    Command[1] := '-';
  128.                    Command[2] := 'P';
  129.                    Cind       := 2;
  130.                 END;
  131.  
  132.          END (* Case *);
  133.  
  134.       END (* BEGIN Esc *)
  135.  
  136.    ELSE                            (* Else pick up letter command *)
  137.       BEGIN
  138.  
  139.          WHILE ( C <> CR ) AND ( Cind < Max_String-1 ) DO
  140.             BEGIN
  141.                IF c = ctrlx THEN
  142.                   BEGIN
  143.                      WRITE(' *** DELETED');
  144.                      WRITEln;
  145.                      GOTO 1;
  146.                   END
  147.                ELSE IF c = bs THEN
  148.                   IF Cind > 0 THEN
  149.                      BEGIN
  150.                         Cind := Cind - 1;
  151.                         WRITE(bs,' ',bs);
  152.                      END
  153.                   ELSE
  154.                ELSE
  155.                  BEGIN
  156.                     Cind          := Cind + 1;
  157.                     Command[Cind] := c;
  158.                     WRITE( CON , c );
  159.                  END;
  160.  
  161.                READ( Kbd , c );
  162.  
  163.             END;
  164.  
  165.       END;
  166.  
  167.                                    (* Insert NUL as last char in command *)
  168.    Command[ Cind + 1 ] := NUL;
  169.    Cind                := 1;
  170.  
  171.    Textcolor( ForeGround_Color );
  172.  
  173. END  (* Read_Command *);
  174.